@extends('admin.layout.layout', ['row' => @$page])
@section('style')
    <style>
        .table .tth{
            background-color: rgba(0, 0, 0, 0.05);
            width: 150px;
            font-weight: bold;
        }
        .table .ttd{
            width: 350px;
        }
        .table .ttt{
            padding: 0;
        }
        .ttt .table{
            margin: 0;
        }
        .ttt .table img + p{
            text-align: center;
            margin: 10px 0 0;
        }
        .tst{
            color: #1e89e0;
            font-weight: 700;
            text-align: center;
            font-size: 1.25rem;
        }
    </style>
@endsection
@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions">
                {{--<div class="item">
                    <a href="/{{ request()->path() }}/create" class="btn btn-sm btn-primary">{{ ts('addnew') }}</a>
                </div>--}}
            </div>
        </div>

        <div>
            <table class="table s3">
                <tbody>
                <tr class="d-none">
                    <td class="tth">{{ ts('SQID') }}</td>
                    <td class="ttd" colspan="5">{{ $data->id }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('baseinformation') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('SDZH') }}</td>
                    <td class="ttd">{{ $data->unique_id }}</td>
                    <td class="tth">{{ ts('SDMC') }}</td>
                    <td class="ttd">{{ $data->abbr }}</td>
                    <td class="tth">{{ ts('companyname') }}</td>
                    <td class="ttd">{{ $data->company_name }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('phonenumber') }}</td>
                    <td class="ttd">{{ $data->extension }} {{ $data->phone_number }}</td>
                    <td class="tth">{{ ts('email') }}</td>
                    <td class="ttd">{{ $data->email_address }}</td>
                    <td class="tth">{{ ts('status') }}</td>
                    <td class="ttd">{{ !empty($data->deleted_at) ? ts('jy') : ( $data->status == 1 ? ts('active') : ts('DEACTIVE') ) }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('SDXZZB') }}</td>
                    <td class="ttd">{{ @$data->warranty_create == 1 ? ts('yes') : ts('no') }}</td>
                    <td class="tth">{{ ts('漆膜任务值') }}</td>
                    <td class="ttd">{{ $user->task_value ?? '' }}</td>
                    <td class="tth">{{ ts('窗膜任务值') }}</td>
                    <td class="ttd">{{ $user->win_task_value ?? '' }}</td>
                </tr>

                <tr>
                    <td colspan="6" class="tst">{{ ts('regionInformation') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('region') }}</td>
                    <td>{{ ts('region_master.'.$data->region_id) }}</td>
                    <td class="tth">{{ ts('province') }}</td>
                    <td>{{ ts('province_master.'.$data->province_id) }}</td>
                    <td class="tth">{{ ts('city') }}</td>
                    <td>{{ ts('cities.'.$data->city) }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('addresss') }}</td>
                    <td colspan="5">{{ $data->address }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('contactinformation') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('XINGMING') }}</td>
                    <td>{{ $data->first_name }}</td>
                    <td class="tth">{{ ts('PHONENUMBER') }}</td>
                    <td>{{ $data->cell_phone }}</td>
                    <td class="tth">{{ ts('WECHATID') }}</td>
                    <td>{{ $data->wechat_id }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('BEIZHU') }}</td>
                </tr>
                <tr>
                    <td colspan="6" height="64">{{ $data->note }}</td>
                </tr>
                </tbody>
            </table>
            <div class="my-4">
                @empty($data->deleted_at)
                    <a href="/{{ request()->path() }}/edit" class="btn btn-primary">{{ ts('edit') }}</a>
                    <button class="btn btn-warning ml-4" onclick="resetPWD({{ $data->id }})">{{ ts('CZMM') }}</button>
                @endif
                    @if(getDDN($data->id))
                        <a href="/{{ request()->path() }}/dealer" class="btn btn-success ml-4">{{ ts('dealer') }}</a>
                    @else
                        <button type="button" disabled class="btn btn-secondary ml-4">{{ ts('dealer') }}</button>
                    @endif
                    @if(getDDPN($data->id))
                        <a href="/{{ request()->path() }}/performance" class="btn btn-primary ml-4">{{ ts('performance') }}</a>
                    @else
                        <button type="button" disabled class="btn btn-secondary ml-4">{{ ts('performance') }}</button>
                    @endif
            </div>
            <h3 class="section_sub_title">{{ ts('LSBGJL') }}</h3>
            <table class="table s3 text-center">
                <thead>
                <tr class="table-secondary">
                    <th>{{ ts('CZY') }}</th>
                    <th>{{ ts('CZe') }}</th>
                    <th>{{ ts('explain') }}</th>
                    <th>{{ ts('CZsj') }}</th>
                </tr>
                @foreach(getUSH($data->id) as $v)
                    <tr>
                        <td>{{ $v->abbr }}</td>
                        <td class="bg-light">{{ ts('urstatus'.$v->status) }}</td>
                        <td class="bg-light">
                            @if($v->status == 9)
                                @foreach(json_decode($v->note, 1) ?: [] as $vn)
                                    <div><b>{{ @$vn['label'] }}</b>：{{ @$vn['old'] }} => {{ @$vn['new'] }}</div>
                                @endforeach
                            @else
                                {{ $v->note }}
                            @endif
                        </td>
                        <td>{{ fdate2($v->created_at) }}</td>
                    </tr>
                @endforeach
                </thead>
            </table>
        </div>


    </div>


@endsection

@section('script')
    <script>
        function resetPWD() {
            var url = '/{{ request()->path() }}/reset_pwd';
            mySwalV2({t:'确定重置密码？', c:'input'}).then(function (d) {
                request.post(url, {
                    note: d
                }).then(function (d) {
                    mySwal2(d.msg)
                }).catch(function (d) {
                    console.log(d)
                })
            }).catch(function (d) {
                console.log(d)
            })
            console.log(url)
        }
    </script>
@endsection
